
[dbo].[SegmentDefinition]
CREATE TABLE [dbo].[SegmentDefinition]
(
[SegmentDefinitionKey] [uniqueidentifier] NOT NULL,
[Name] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SegmentDefinition_Name] DEFAULT (''),
[Description] [nvarchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SegmentDefinition_Description] DEFAULT (''),
[QueryDocumentKey] [uniqueidentifier] NULL,
[ExecutionOrder] [int] NOT NULL CONSTRAINT [DF_SegmentDefinition_ExecutionOrder] DEFAULT ((0)),
[IsJobNSelect] [bit] NOT NULL CONSTRAINT [DF_SegmentDefinition_IsJobNSelect] DEFAULT ((0)),
[NSelectElements] [int] NOT NULL CONSTRAINT [DF_SegmentDefinition_NSelectElements] DEFAULT ((0)),
[UpdatedByUserKey] [uniqueidentifier] NOT NULL,
[UpdatedOn] [datetime] NOT NULL,
[CreatedByUserKey] [uniqueidentifier] NOT NULL,
[CreatedOn] [datetime] NOT NULL,
[SegmentationJobKey] [uniqueidentifier] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SegmentDefinition] ADD CONSTRAINT [PK_SegmentDefinition] PRIMARY KEY CLUSTERED ([SegmentDefinitionKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_SegmentDefinition_CreatedByUserKey] ON [dbo].[SegmentDefinition] ([CreatedByUserKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_SegmentDefinition_SegmentationJobKey] ON [dbo].[SegmentDefinition] ([SegmentationJobKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_SegmentDefinition_UpdatedByUserKey] ON [dbo].[SegmentDefinition] ([UpdatedByUserKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SegmentDefinition] ADD CONSTRAINT [FK_SegmentDefinition_ListMain] FOREIGN KEY ([SegmentDefinitionKey]) REFERENCES [dbo].[ListMain] ([ListKey])
GO
ALTER TABLE [dbo].[SegmentDefinition] ADD CONSTRAINT [FK_SegmentDefinition_SegmentationJob] FOREIGN KEY ([SegmentationJobKey]) REFERENCES [dbo].[SegmentationJob] ([SegmentationJobKey])
GO
ALTER TABLE [dbo].[SegmentDefinition] ADD CONSTRAINT [FK_SegmentDefinition_UniformRegistry] FOREIGN KEY ([SegmentDefinitionKey]) REFERENCES [dbo].[UniformRegistry] ([UniformKey])
GO
ALTER TABLE [dbo].[SegmentDefinition] ADD CONSTRAINT [FK_SegmentDefinition_UserMain_CreatedBy] FOREIGN KEY ([CreatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO
ALTER TABLE [dbo].[SegmentDefinition] ADD CONSTRAINT [FK_SegmentDefinition_UserMain_UpdatedBy] FOREIGN KEY ([UpdatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO